<template>
    <el-button @click="btnClick" type="primary"> {{ "视频取帧" }} </el-button>
</template>

<script>
import { gVideoFrame } from "@/module/useFfmpeg";
import { interval } from "@/utils/string";
export default {
    props: ["obj"],
    computed: {
        tickCounts() {
            let videoInfo = this.obj.videoList[this.obj.videoSelected] || {};
            return videoInfo.duration >= 20
                ? 20
                : Math.floor(videoInfo.duration);
        },
    },
    methods: {
        async btnClick() {
            let selectedVideo = this.obj.videoList[this.obj.videoSelected];
            // 需先上传视频
            if (!selectedVideo) {
                alert("请先上传视频");
                return;
            }
            let tmp = await gVideoFrame(
                selectedVideo.videoUrl,
                interval(selectedVideo.duration),
                selectedVideo.fileName,
                this.tickCounts
            );
            this.$set(
                this.obj.videoList[this.obj.videoSelected],
                "frameList",
                tmp
            );
        },
    },
};
</script>